mod usrtos;
use std::ffi::{CString};
use usrtos::Context;
use usrtos::RawMemory;
use usrtos::UBox;
use std::sync::atomic::AtomicUsize;

fn main() {
    let tmpdir = CString::new("/tmp/usrtos").unwrap();
    let mut ctx = Context::new(tmpdir);

    let mem = RawMemory::new(&mut ctx,CString::new("log0").unwrap());
    for i in 0..8 {
        let gp = mem.alloc_gp(128 as u64);
        match gp {
            Some(g) => println!("{}", g),
            None => println!("None"),
        }
    }
    for i in 0..8 {
        let b = UBox::new(32i32,&mem);
        println!("{} {}",i,b);
    }
    let a = AtomicUsize::new(0);
    println!("before {:?}",a);
    
    let spin = UBox::new(a,&mem);
    println!("after {:?} {}",*spin,spin);
}
